HIDING: 3
};
+// Message tray has its custom Urgency enumeration. LOW, NORMAL and CRITICAL
+// urgency values map to the corresponding values for the notifications received
+// through the notification daemon. HIGH urgency value is used for chats received
+// through the Telepathy client.
+const Urgency = {
+ LOW: 0,
+ NORMAL: 1,
+ HIGH: 2,
+ CRITICAL: 3
+}
+
function _fixMarkup(text, allowMarkup) {
if (allowMarkup) {
// Support &, ", ', < and >, escape all other
Notification.prototype = {
_init: function(source, title, banner, params) {
this.source = source;
- this.urgent = false;
+ this.urgency = Urgency.NORMAL;
this.resident = false;
// 'transient' is a reserved keyword in JS, so we have to use an alternate variable name
this.isTransient = false;
this._updated();
},
- setUrgent: function(urgent) {
- this.urgent = urgent;
+ setUrgency: function(urgency) {
+ this.urgency = urgency;
},
setResident: function(resident) {
} else if (this._notificationQueue.indexOf(notification) < 0) {
notification.connect('destroy',
Lang.bind(this, this.removeNotification));
-
- if (notification.urgent)
- this._notificationQueue.unshift(notification);
- else
- this._notificationQueue.push(notification);
+ this._notificationQueue.push(notification);
+ this._notificationQueue.sort(function(notification1, notification2) {
+ return (notification2.urgency - notification1.urgency);
+ });
}
-
this._updateState();
},
onCompleteScope: this
});
- // We auto-expand urgent notifications.
+ // We auto-expand notifications with CRITICAL urgency.
// We call _expandNotification() again on the notifications that
// are expanded in case they were in the process of hiding and need
// to re-expand.
- if (this._notification.urgent || this._notification.expanded)
+ if (this._notification.urgency == Urgency.CRITICAL || this._notification.expanded)
// This will overwrite the y tween, but leave the opacity
// tween, and so the onComplete will remain as well.
this._expandNotification(true);
},
// We use this function to grab focus when the user moves the pointer
- // to an urgent notification that was already auto-expanded.
+ // to a notification with CRITICAL urgency that was already auto-expanded.
_ensureNotificationFocused: function() {
this._notification.grabFocus(false);
},
for (let i = 0; i < actions.length - 1; i += 2)
notification.addButton(actions[i], actions[i + 1]);
}
-
- notification.setUrgent(hints.urgency == Urgency.CRITICAL);
+ switch (hints.urgency) {
+ case Urgency.LOW:
+ notification.setUrgency(MessageTray.Urgency.LOW);
+ break;
+ case Urgency.NORMAL:
+ notification.setUrgency(MessageTray.Urgency.NORMAL);
+ break;
+ case Urgency.CRITICAL:
+ notification.setUrgency(MessageTray.Urgency.CRITICAL);
+ break;
+ }
notification.setResident(hints.resident == true);
// 'transient' is a reserved keyword in JS, so we have to retrieve the value
// of the 'transient' hint with hints['transient'] rather than hints.transient